package com.zaprk.service.impl;

import com.zaprk.exception.FindByIdNotFoundException;
import com.zaprk.mapper.IPersonMapper;
import com.zaprk.pojo.Person;
import com.zaprk.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @PackageName: com.zaprk.service.impl
 * @ClassName: PersonServiceImpl
 * @Description:
 * @author: RZS
 * @date: 2024/3/11  11:35
 */
@Service
public class PersonServiceImpl implements IPersonService {

    @Autowired
    private IPersonMapper personMapper;

    @Override
    public Person findById(Integer id) throws FindByIdNotFoundException {
        Person person = personMapper.selectById(id);
        if (person == null) {
            throw new FindByIdNotFoundException("没有查找到数据异常");
        }
        return person;
    }

    @Override
    public String number() {
        int num = 1 / 0;
        return "num: " + num;
    }
}
